home *** CD-ROM | disk | FTP | other *** search
/ Chip: 2005 Utilities / CHIP Utilities 2005.7z / CHIP Utilities 2005.iso / docs / maxblast / www.maxtor.com / maxtor / en_us / scripts / nav.js < prev   
Text File  |  2004-07-09  |  9KB  |  301 lines

  1. use("thing.mouse.local");
  2.  
  3. var tempfolders = location.pathname.toLowerCase().replace("index.htm", "").split("/");
  4. var folders = new Array();
  5. for( var i=1; i<tempfolders.length; i++ ){
  6.     if( tempfolders[i] != '' ){
  7.         folders[ folders.length ] = tempfolders[i];
  8.     }
  9. }
  10. tempfolders = null;
  11.  
  12. /********************************************************************************
  13.  
  14.     Nav construction
  15.  
  16. ********************************************************************************/
  17. function Nav( name, title, parent, isBig, isUtilNav, url ){
  18.     this.name = name;
  19.     this.title = title;
  20.     this.parent = parent;
  21.     this.path = this.url;
  22.     this.kids = new Array();
  23.     this.tier = (this.parent) ? this.parent.tier + 1 : 0;
  24.     this.isBig = isBig;
  25.     this.isUtilNav = isUtilNav;
  26.     this.url = url;
  27.     this.path = this.url;
  28.     this.isCurrent = (this.parent) ? this.parent.isCurrent && folders[this.tier] == this.name : true;
  29.  
  30.     if( this.parent ){
  31.         if( this.parent.isCurrent ){
  32.             if( folders[this.tier] == this.name ) this.isCurrent = true;
  33.             else if( folders[this.tier] == null && this.name == '' ) this.isCurrent=true;
  34.             else this.isCurrent = false;
  35.         }
  36.         else{
  37.             this.isCurrent = false;
  38.         }
  39.     }
  40.     else{
  41.         this.isCurrent = true; // root
  42.     }
  43.     if( this.isCurrent ){
  44.         Nav.currentNav = this;
  45.         if( this.parent && ! Nav.currentT1 ){
  46.             Nav.currentT1 = this;
  47.         }
  48.     }
  49. }
  50. Nav.currentNav = null;
  51. Nav.currentT1 = null;
  52. Nav.prototype.add = function( name, title, isBig, isUtilNav, url){
  53.  
  54.     return this.kids[ this.kids.length ] = new Nav( name, title, this, isBig, isUtilNav, url);
  55. }
  56.  
  57. /********************************************************************************
  58.  
  59.     html writing
  60.  
  61. ********************************************************************************/
  62. Nav.globalNav = function(){
  63.     var htmlDropdowns = '';
  64.  
  65.     for( var i=0; i<Nav.root.kids.length; i++ ){
  66.         htmlDropdowns += Nav.root.kids[i].dropdown();
  67.     }
  68.  
  69.     return htmlDropdowns;
  70. }
  71. Nav.prototype.dropdown = function(){
  72.     if( ! this.isBig ) return '';
  73.     var html = '<div id="navDrop' + this.name + 'Div" class="navDrop">\n';
  74.  
  75.     for( var i=0; i<this.kids.length; i++ ){
  76.         html += this.kids[i].dropdownRow(i);
  77.     }
  78.     html += '</div>\n\n';
  79.     return html;
  80. }
  81. Nav.prototype.dropdownRow = function(index){
  82.     var cssClass = (index == 0) ? 'navDropRow0' : 'navDropRow';
  83.     if( is.ns4 ){
  84.         return '<div class="' + cssClass + '"><a href="' + this.path + '">' + this.title.replace(/\s/gi, ' ') + '</a></div>\n';
  85.     }
  86.     else{
  87.         return '<div href="' + this.path + '" onclick="location.href=\'' + this.path + '\'" onmouseover="navDropOver(this)" onmouseout="navDropOut(this)" class="' + cssClass + '">' + this.title.replace(/\s/gi, ' ') + '</div>\n';
  88.     }
  89. }
  90.  
  91. function leftnavHTML(){
  92.     var html = '';
  93.     if( Nav.currentT1 ){
  94.         html += '<table width="178" border="0" cellpadding="0" cellspacing="0">'
  95.         + Nav.currentT1.leftnav()
  96.         + '</table><img src="/maxtor/en_us/images/pixel.gif" width="1" height="40" border="0" alt=""><br>';
  97.     }
  98.     return html;
  99. }
  100.  
  101. function utilnavHTML(){
  102.     var html = '';
  103.     html += '<table width="178" border="0" cellpadding="0" cellspacing="0">'
  104.     + Nav.currentNav.utilnav()
  105.     + '</table>';
  106.     return html;
  107. }
  108.  
  109. Nav.prototype.getLeftnavCssClass = function(){
  110.     return ( this.isCurrent )
  111.         ? 'leftnavT' + this.tier + 'on'
  112.         : 'leftnavT' + this.tier + 'off';
  113. }
  114. Nav.prototype.getLeftnavLineCssClass = function(i){
  115.     return( (i==0 && this.tier == 3)                                         // first of the tier 3's
  116.         ||    (this.tier == 2 && i>0  && this.parent.kids[i-1].isCurrent) )     // first of the tier 2's after the current
  117.         ? this.parent.getLeftnavCssClass() + 'Line'
  118.         : this.getLeftnavCssClass() + 'Line';
  119. }
  120.  
  121. Nav.prototype.leftnav = function(){
  122.     var html = '';
  123.  
  124.     if( this.tier > 1 ){
  125.         html += '<tr><td class="' + this.getLeftnavCssClass() + '" onclick="location.href=\'' + this.path + '\'"> <a href="' + this.path + '">' + this.title + '</a></td></tr>';
  126.     }
  127.  
  128.     if( this.isCurrent && this.tier < 3 ){
  129.         for( var i=0; i<this.kids.length; i++ ){
  130.             if( this.tier + i > 1 || this.isCurrent ){
  131.                 html += '<tr><td class="' + this.kids[i].getLeftnavLineCssClass(i) + '"><img src="/maxtor/en_us/images/dottedLine_178.gif" width="178" height="1" alt="-" border="0"></td></tr>';
  132.             }
  133.             html += this.kids[i].leftnav();
  134.  
  135.             //if last & current, draw the line
  136.             if( this.kids[i].isCurrent && (this.kids.length -1 == i) ) html += '<tr><td class="leftnavT2onLine"><img src="/maxtor/en_us/images/dottedLine_178.gif" width="178" height="1" alt="-" border="0"></td></tr>';
  137.         }
  138.     }
  139.     return html;
  140. }
  141.  
  142. Nav.prototype.utilnav = function(){
  143.     var tdClass = '';
  144.     var html = '';
  145.     var gotOne = false;
  146.  
  147.     for( var i=0; i<Nav.root.kids.length; i++ ){
  148.  
  149.         if( Nav.root.kids[i].isUtilNav ){
  150.  
  151.             //if you're the first util nav, write a white line
  152.             if( Nav.root.kids[i].isCurrent && !gotOne  ) html += '<tr><td class="leftnavT2onLine"><img src="/maxtor/en_us/images/dottedLine_178.gif" width="178" height="1" alt="-" border="0"></td></tr>';
  153.  
  154.             tdClass = ( Nav.root.kids[i].isCurrent ) ? 'leftnavT2on' :    'leftnavT2off';
  155.  
  156.             //links
  157.             html += '<tr><td class="' + tdClass + '" onclick="location.href=\'' + Nav.root.kids[i].path + '\'"> <a href="' + Nav.root.kids[i].path + '">' + Nav.root.kids[i].title + ' </a></td></tr>';
  158.  
  159.             //draw a line if your aren't last or your are current
  160.             if( i < Nav.root.kids.length-1 || Nav.root.kids[i].isCurrent ){
  161.                 // line is solid if you are current or next is current
  162.                 if( i < Nav.root.kids.length-1 && Nav.root.kids[i+1].isCurrent ) tdClass = 'leftnavT2on'
  163.                 html += '<tr><td class="' + tdClass + 'Line"><img src="/maxtor/en_us/images/dottedLine_178.gif" width="178" height="1" alt="-" border="0"></td></tr>';
  164.  
  165.             }
  166.         gotOne = true;
  167.         }
  168.     }
  169.     return html;
  170. }
  171.  
  172.  
  173. /********************************************************************************
  174.  
  175.     initialization
  176.  
  177. ********************************************************************************/
  178. Nav.init = function(){
  179.     for( var i=0; i<Nav.root.kids.length; i++ ){
  180.         Nav.root.kids[i].initT1();
  181.     }
  182. }
  183. Nav.prototype.initT1 = function(){
  184.  
  185.     this.thing = Thing.all['nav' + this.name];
  186.     if( ! this.thing ) return;
  187.  
  188.     this.thing.nav = this;
  189.  
  190.     if( this.isBig ){
  191.         this.thing.captureMouseClick( thing_navMouseClick );
  192.         this.thing.captureMouseMove( thing_navMouseMove );
  193.         this.thing.captureMouseOut( thing_navMouseOut );
  194.         this.dropThing = Thing.all['navDrop' + this.name];
  195.         this.dropThing.moveTo( this.thing.position.add(0, 26) );
  196.         this.dropThing.nav = this;
  197.         this.dropThing.captureMouseMove(thing_navMouseMove);
  198.         this.dropThing.captureMouseOut(thing_navMouseOut);
  199.     }
  200.     else{
  201.         this.thing.captureMouseClick( thing_navSmallClick );
  202.         this.thing.captureMouseMove( thing_navSmallMove );
  203.         this.thing.captureMouseOut( thing_navSmallOut );
  204.     }
  205.     if( this.isCurrent ){
  206.         this.thing.setBackground("#000000");
  207.         if( !this.isBig ) this.thing.div.className = 'navT1smallon';
  208.     }
  209. }
  210. init("Nav.init()");
  211.  
  212. /********************************************************************************
  213.  
  214.     mouse activity
  215.  
  216. ********************************************************************************/
  217. Nav.currDrop = null;
  218. Nav.prototype.setCurr = function(){
  219.     clearTimeout( this.hideTimeout );
  220.     clearTimeout( this.showTimeout );
  221.     if( Nav.currDrop && Nav.currDrop != this ){
  222.         Nav.currDrop.thing.hideNav();
  223.     }
  224.     Nav.currDrop = this;
  225.     this.showTimeout = setTimeout( this.dropThing.name + '.show()' , 100 );
  226.     if( is.ns4 ) this.hideTimeout = setTimeout( this.dropThing.name + '.hide()', 1250 );
  227. }
  228. Thing.prototype.showNav = function(){
  229.     this.setBackground("black");
  230.     this.nav.dropThing.name.show();
  231. }
  232. Thing.prototype.hideNav = function(){
  233.     if( ! this.nav.isCurrent ){
  234.         //this.setBackground( "#002c84");
  235.     }
  236.     this.nav.dropThing.hide();
  237. }
  238.  
  239. function thing_navMouseClick(p){
  240.     location.href = this.nav.path;
  241.     return false;
  242. }
  243. function thing_navMouseMove(p){
  244.     this.nav.setCurr();
  245.     if( this.name == "nav" + this.nav.name ){
  246.         setStatusHref( this.nav.path );
  247.     }
  248.     return false;
  249. }
  250. function thing_navMouseOut(p){
  251.     clearTimeout( this.nav.hideTimeout );
  252.     clearTimeout( this.nav.showTimeout );
  253.     this.nav.hideTimeout = setTimeout( this.nav.thing.name + '.hideNav()', 100 );
  254.     return true;
  255. }
  256. function navMouseover(name){
  257.     if( Thing.all[name] ){
  258.         Thing.all[name].mouseMove();
  259.     }
  260. }
  261.  
  262.  
  263.  
  264.  
  265. function thing_navSmallClick(p){
  266.     location.href = this.nav.path;
  267. }
  268. function thing_navSmallMove(p){
  269.     this.div.className = "navT1smallOn";
  270.     mouseover( this.name + "Img" );
  271.     setStatusHref(this.nav.path);
  272. }
  273. function thing_navSmallOut(p){
  274.     this.div.className = "navT1small";
  275.     mouseout( this.name + "Img" );
  276.     setStatusHref('');
  277. }
  278.  
  279.  
  280.  
  281.  
  282.  
  283. function navDropOver(who){
  284.     setStatusHref(who.href);
  285.     who.style.background = '#002c84';
  286. }
  287. function navDropOut(who){
  288.     setStatusHref('');
  289.     who.style.background = '#8AA8D8';
  290. }
  291.  
  292.  
  293.  
  294. function setStatusHref(url){
  295.     if( url != null && url != '' && url.indexOf("http://") != 0 ){
  296.         url = 'http://' + location.hostname + url;
  297.     }
  298.     status = url;
  299. }
  300.  
  301.